<template>
  <a-card :bordered="false">
    <bis-ali-oss-form ref="realForm" @ok="getList" :disabled="disableSubmit"></bis-ali-oss-form>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import BisAliOssForm from './modules/BisAliOssForm'

export default {
  name: 'BisAliOssList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    BisAliOssForm
  },
  data() {
    return {
      description: '阿里OSS存储管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: this.$t('阿里AccessKeyID'),
          align: 'center',
          dataIndex: 'accessKeyId'
        },
        {
          title: this.$t('阿里AccessKeySecret'),
          align: 'center',
          dataIndex: 'accessKeySecret'
        },
        {
          title: this.$t('服务器位置'),
          align: 'center',
          dataIndex: 'regionId'
        },
        {
          title: this.$t('oss存储名称'),
          align: 'center',
          dataIndex: 'bucketname'
        },
        {
          title: this.$t('备注'),
          align: 'center',
          dataIndex: 'commet'
        },
        {
          title: this.$t('操作'),
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/oss/bisAliOss/list',
        delete: '/oss/bisAliOss/delete',
        deleteBatch: '/oss/bisAliOss/deleteBatch',
        exportXlsUrl: '/oss/bisAliOss/exportXls',
        importExcelUrl: 'oss/bisAliOss/importExcel'
      },
      dictOptions: {},
      superFieldList: [],
      disableSubmit: false
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  watch:{
    dataSource(list){
      if(list.length>0){
        this.$refs.realForm.edit(list[0])
      }else{
        this.$refs.realForm.add()
      }
    }
  },
  methods: {
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'accessKeyId', text: this.$t('阿里AccessKeyID'), dictCode: '' })
      fieldList.push({ type: 'string', value: 'accessKeySecret', text: this.$t('阿里AccessKeySecret'), dictCode: '' })
      fieldList.push({ type: 'string', value: 'regionId', text: this.$t('服务器位置'), dictCode: '' })
      fieldList.push({ type: 'string', value: 'bucketname', text: this.$t('oss存储名称'), dictCode: '' })
      fieldList.push({ type: 'string', value: 'commet', text: this.$t('备注'), dictCode: '' })
      this.superFieldList = fieldList
    },
    getList(){
      this.searchQuery()
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>